package main

import (
	"fmt"
	"go-gin-example/models"
	"go-gin-example/pkg/gredis"
	"go-gin-example/pkg/logging"
	"go-gin-example/pkg/setting"
	"net/http"

	// "github.com/gin-gonic/gin"
	// "gitee.com/code_fun/go/src/go-gin-example/pkg/setting"
	"go-gin-example/routers"
)

//web的启动函数，这里使用main1主要用于测试其他功能，web需要把其他的main注释
func main() {

	// 第一版 后面使用router.go替换
	//router := gin.Default()
	// 创建http方法绑定到handlers
	// router.GET("/test", func(c *gin.Context) {
	// 	c.JSON(200, gin.H{
	// 		"message": "test",
	// 	})
	// })

	setting.Setup()
	logging.Setup()
	models.Setup()
	gredis.Setup()

	router := routers.InitRouter()

	s := &http.Server{
		Addr:           fmt.Sprintf(":%d", setting.ServerSetting.HttpPort),
		Handler:        router,
		ReadTimeout:    setting.ServerSetting.ReadTimeout,
		WriteTimeout:   setting.ServerSetting.WriteTimeout,
		MaxHeaderBytes: 1 << 20,
	}

	s.ListenAndServe()
}
